﻿$(function () {
    $("#records").ggrid({
        url: '/Donations/OneTimeGridLoad',
        dataType: 'json',
        columns: [
		    { display: 'Email', name: 'Member.Email', width: 40, sortable: true, align: 'left' },
		    { display: 'FirstName', name: 'Member.FirstName', width: 180, sortable: true, align: 'left' },
		    { display: 'LastName', name: 'Member.LastName', width: 120, sortable: true, align: 'left' },
            { display: 'Amount', name: 'Amount', width: 120, sortable: true, align: 'left' },
            { display: 'Status', name: 'Status', width: 40, sortable: true, align: 'left', formatFunction: formatOneTimeStatus },
            { display: 'EnteredOn', name: 'EnteredOn', width: 120, sortable: true, align: 'left', formatFunction: formatDate }
		],
        actions: [
		],
        defaultSort: "EnteredOn",
        defaultSortOrder: "desc",
        usePaging: true,
        pageSize: 10,
        width: 'auto',
        height: 'auto'
    });

    $("#records2").ggrid({
        url: '/Donations/RecurringGridLoad',
        dataType: 'json',
        columns: [
		    { display: 'Email', name: 'Member.Email', width: 40, sortable: true, align: 'left' },
		    { display: 'FirstName', name: 'Member.FirstName', width: 180, sortable: true, align: 'left' },
		    { display: 'LastName', name: 'Member.LastName', width: 120, sortable: true, align: 'left' },
            { display: 'Amount', name: 'Amount', width: 120, sortable: true, align: 'left' },
            { display: 'Status', name: 'Status', width: 40, sortable: true, align: 'left', formatFunction: formatRecurringStatus },
            { display: 'EnteredOn', name: 'EnteredOn', width: 120, sortable: true, align: 'left', formatFunction: formatDate }
		],
        actions: [
		],
        defaultSort: "EnteredOn",
        defaultSortOrder: "desc",
        usePaging: true,
        pageSize: 10,
        width: 'auto',
        height: 'auto'
    });
});

function formatOneTimeStatus(d) {
    if (d == "1") {
        return "Not Confirmed";
    } else if (d == "2") {
        return "Pending";
    } else if (d == "3") {
        return "Complete";
    } else if (d == "4") {
        return "Canceled";
    } else if (d == "5") {
        return "Failed";
    }
}

function formatRecurringStatus(d) {
    if (d == "1") {
        return "Not Confirmed";
    } else if (d == "2") {
        return "Pending";
    } else if (d == "3") {
        return "Complete";
    } else if (d == "4") {
        return "Canceled";
    } else if (d == "5") {
        return "Failed";
    }
}
